<?php
include_once("../initial.php");
include_once("../dbdriver/classWHandle.php");
include_once("../dbdriver/classRHandle.php");
class classLogic
{
    public function insert_class($array)
    {
        if(is_array($array)==false)
        {
            return false;
        }
        if(count($array)==0)
        {
            return false;
        }
        $whandle = new classWHandle();
        return $whandle->insert_class($array);
    }
    public function get_class_num()
    {
        $rhandle = new classRHandle();
        return $rhandle->get_class_num();
    }
    public function get_class($array='', $orderby="",$limit="")
    {
        $rhandle = new classRHandle();
        if($array == '')
        {
            return $rhandle->get_all_data($orderby,$limit);
        }
        else
        {
            return $rhandle->get_some_data($array,$orderby,$limit);
        }
    }
    public function update_class($array,$id)
    {
        $whandle = new classWHandle();
        if($id=="")
        {
            return false;
        }
        return $whandle->update_class($array,$id);
    }
    public function delete_class($id)
    {
        $whandle = new classWHandle();
        if($id=="")
        {
            return false;
        }
        return $whandle->delete_class($id);
    }
    public function searchByKeyword($keyword)
    {
    		if(strlen($keyword)<3)
    		{
    				return array();
    		}
    		$cr = new classRHandle();
    		return $cr->searchByKeyword($keyword, "limit 0, 30");
    }
}
?>
